#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char const *argv[])
{
    int fd = open("/dev/xxx_example_chardev",O_RDWR); // 读写
    if(fd == -1)
    {
        perror("open err");
        return -1;
    }

    char c = 'c';
    int nbytes = write(fd,&c,1);
    if(nbytes == -1)
    {
        perror("write err：\n");
        return -1;
    }

    nbytes = read(fd,'c',1);
    if(nbytes == -1)
    {
        perror("read err:\n");
        return -1;
    }

    close(fd);

    return 0;
}

